package com.lost.octopus.es.processor.scheduler.entity;

import lombok.Data;
import lombok.extern.log4j.Log4j2;

import java.util.List;

/**
 * 调度进度
 * @author zhangbh
 * @date 2025/4/21 10:01
 */
@Data
@Log4j2
public class SyncProgress {

    private Integer maxId;
    private Integer dataCount = 0;
    private Integer currentPage = 1;

    /**
     * 调度名称
     */
    private String scheduleLabel;

    public SyncProgress(Integer maxId, String scheduleLabel, Integer dataCount) {
        this.maxId = maxId;
        this.scheduleLabel = scheduleLabel;
        this.dataCount = dataCount;
    }

    void maxId(Integer maxId) {
        this.maxId = maxId;
    }

    void addCount(Integer count) {
        dataCount += count;
    }

    public void record(List<Integer> mainTabIds, int dataCount) {
        currentPage++;
        addCount(dataCount);
        maxId(mainTabIds.get(mainTabIds.size() - 1));
    }

    public void print() {
        log.info("{} 调度完成，共 {} 条数据 maxId {} page {}", scheduleLabel, dataCount, maxId, currentPage);
    }
}
